package com.qf.controller;

import com.qf.entity.City;
import com.qf.entity.R;
import com.qf.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (City)表控制层
 *
 * @author makejava
 * @since 2020-09-15 12:19:09
 */
@RestController
@RequestMapping("/city")
public class CityController {
    /**
     * 服务对象
     */
    @Autowired
    private CityService cityService;
    @RequestMapping("/list")
    public R<List<City>> list(){
        List<City> cityList = cityService.list();
        return new R<List<City>>().setData(cityList);
    }
    @RequestMapping("/insert")
    public R<Boolean> insert(@RequestBody City city){
        boolean save = cityService.save(city);
        return new R<Boolean>().setData(save);
    }
    @RequestMapping("/getById")
    public R<City> queryCityById(@RequestParam Integer id){
        City city = cityService.getById(id);
        return new R<City>().setData(city);
    }
}